import { request } from "@/utils/service"

/**
 * 获取角色用户列表数据
 */
export function getRoleUserList(params) {
  return request({
    url: "/sjw_department_control/sys/role/page",
    method: "post",
    params: params
  })
}

/**
 * 获取角色对应的菜单 ID 列表
 */
export function getRoleMenuIds(data) {
  return request({
    url: "/sjw_department_control/sys/role/menuIds",
    method: "post",
    data: data
  })
}

/**
 * 保存角色信息
 */
export function saveRole(data) {
  return request({
    url: "/sjw_department_control/sys/role/save",
    method: "post",
    data
  })
}

/**
 * 更新角色状态
 */
export function updateRoleStatus(params) {
  return request({
    url: "/sjw_department_control/sys/role/updateStatus",
    method: "post",
    params
  })
}

/**
 * 删除角色
 */
export function deleteRole(params) {
  return request({
    url: "/sjw_department_control/sys/role/delete",
    method: "post",
    params
  })
}

/**
 * 为角色分配用户
 */
export function assignUsersToRole(data) {
  return request({
    url: "/sjw_department_control/sys/role/assignUsers",
    method: "post",
    data
  })
}

/**
 * 批量禁用角色
 * @param {Array} ids - 要禁用的角色 ID 数组
 * @returns {Promise} 一个包含请求结果的 Promise 对象
 */
export function batchDisableRoles(data) {
  return request({
    url: "/sjw_department_control/sys/role/batchDisable",
    method: "put",
    data
  })
}

/**
 * 批量启用角色
 * @param {Array} ids - 要启用的角色 ID 数组
 * @returns {Promise} 一个包含请求结果的 Promise 对象
 */
export function batchEnableRoles(data) {
  return request({
    url: "/sjw_department_control/sys/role/batchActivation",
    method: "put",
    data
  })
}

export function getMenuByRoleId(params) {
  return request({
    url: "/sjw_department_control/sys/role/menuIds",
    method: "post",
    params
  })
}

// 数据权限指标树
export function getTree() {
  return request({
    url: "/sjw_department_control/cockpitMetricsTree/tree",
    method: "post"
  })
}
